package com.yjq.programmer.controller.app;

import com.yjq.programmer.dto.ResponseDTO;
import com.yjq.programmer.dto.UserDTO;
import com.yjq.programmer.service.IUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 杨杨吖
 * @QQ 823208782
 * @WX yjqi12345678
 * @create 2022-11-10 9:28
 */
@RestController("AppUserController")
@RequestMapping("/app/user")
public class UserController {

    @Resource
    private IUserService userService;

    /**
     * 小程序用户登录操作处理
     * @param userDTO
     * @return
     */
    @PostMapping("/login")
    public ResponseDTO<UserDTO> appLogin(@RequestBody UserDTO userDTO){
        return userService.appLogin(userDTO);
    }


    /**
     * 小程序获取当前登录用户
     * @param userDTO
     * @return
     */
    @PostMapping("/getLoginUser")
    public ResponseDTO<UserDTO> appGetLoginUser(@RequestBody UserDTO userDTO){
        return userService.getLoginUser(userDTO);
    }

    /**
     * 小程序用户注册操作
     * @param userDTO
     * @return
     */
    @PostMapping(value="/register")
    @ResponseBody
    public ResponseDTO<Boolean> appRegister(@RequestBody UserDTO userDTO){
        return userService.register(userDTO);
    }

    /**
     * 小程序修改个人信息
     * @param userDTO
     * @return
     */
    @PostMapping(value="/editInfo")
    @ResponseBody
    public ResponseDTO<Boolean> appEditUserInfo(@RequestBody UserDTO userDTO){
        return userService.saveUser(userDTO);
    }
}
